package com.lesson4.factorymethod.pizzastore.order;

import com.lesson4.factorymethod.pizzastore.pizza.Pizza;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author 朝花不迟暮
 * @version 1.0
 * @date 2020/8/27 11:42
 */
public abstract class OrderPizza
{
    abstract Pizza createPizza(String orderType);

    public OrderPizza()
    {
        Pizza pizza = null;
        String orderType;
        do
        {
            orderType = getType();
            pizza = createPizza(orderType);

            pizza.prepare();
            pizza.bake();
            pizza.cut();
            pizza.box();

        } while (true);

    }


    private String getType()
    {
        try
        {
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("input pizza 种类：");
            String line = reader.readLine();
            return line;
        } catch (IOException e)
        {
            e.printStackTrace();
            return "";
        }
    }
}
